package com.xique.park.controller.web;

import com.xique.common.core.web.domain.AjaxResult;
import com.xique.common.log.annotation.Log;
import com.xique.common.log.enums.BusinessType;
import com.xique.common.security.annotation.PreAuthorize;
import com.xique.park.bean.request.web.passAuth.PassAuthDownRequest;
import com.xique.park.bean.request.web.passAuth.PassAuthListRequest;
import com.xique.park.bean.request.web.passAuth.PassAuthSaveRequest;
import com.xique.park.service.biz.service.IParkCarPassAuthBizService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 车辆管理类型通道通行权限Controller
 *
 * @author xique
 */
@RestController
@RequestMapping("/web/passAuth")
public class WebParkCarPassAuthController {

    @Autowired
    private IParkCarPassAuthBizService parkCarPassAuthBizService;

    /**
     * 查询车辆管理类型权限通行列表
     */
    @PostMapping("/list")
    @PreAuthorize(hasPermi = "park:passAuth:list")
    public AjaxResult passAuthList(@Validated @RequestBody PassAuthListRequest request) {
        return parkCarPassAuthBizService.getPassAuthList(request);
    }

    /**
     * 保存通道通行权限列表
     */
    @PreAuthorize(hasPermi = "park:passAuth:edit")
    @Log(title = "通行权限", businessType = BusinessType.UPDATE)
    @PostMapping("/save")
    public AjaxResult savePassAuthList(@Validated @RequestBody PassAuthSaveRequest request) {
        return parkCarPassAuthBizService.savePassAuthList(request);
    }

    /**
     * 批量下发管理类型通行权限至设备（下发部分和全部通用）
     */
    @PreAuthorize(hasPermi = "parking:all:online")
    @PostMapping("/downPassAuth")
    @Log(title = "通行权限", businessType = BusinessType.COMMAND)
    public AjaxResult downPassAuth(@Validated @RequestBody PassAuthDownRequest request) {
        return parkCarPassAuthBizService.downPassAuthList(request);
    }

}
